home *** CD-ROM | disk | FTP | other *** search
/ Interactive Quarterly / The Best of New Machine Publishing 1 - Disc 4: Interactive Quarterly.iso / pc / demos / az / cyberx.dxr / 00189_CARGA.ls < prev    next >
Encoding:
Text File  |  1996-10-06  |  4.1 KB  |  131 lines

  1. on carga Niv, Sala, Primero
  2.   set Primero to Primero - 1
  3.   set MaxCol to 0
  4.   set TabLinIni to []
  5.   if the machineType = 256 then
  6.     openXLib(the pathName & "fileio.dll")
  7.   end if
  8.   set Fichero to FileIO(mnew, "read", the pathName & "Niv" & Niv & Sala & ".txt")
  9.   if objectp(Fichero) then
  10.     set fich to Fichero(mReadFile)
  11.     set max to length(fich)
  12.     set i to 0
  13.     repeat while i < max
  14.       set i to i + 1
  15.       set car to char i to i of fich
  16.       set linea to EMPTY
  17.       repeat while (i <= max) and (charToNum(car) <> 10)
  18.         if getOne(["Z", "-", "X", "\", "/", "|", " "], car) then
  19.           set linea to linea & car
  20.         else
  21.           if charToNum(car) = 13 then
  22.             nothing()
  23.           else
  24.             alert("car√°cter desconocido : " & car && chartnum(car))
  25.           end if
  26.         end if
  27.         set i to i + 1
  28.         set car to char i to i of fich
  29.       end repeat
  30.       repeat while the last char in linea = " "
  31.         set linea1 to char 1 to length(linea) - 1 of linea
  32.         set linea to linea1
  33.       end repeat
  34.       add(TabLinIni, linea)
  35.     end repeat
  36.     Fichero(mdispose)
  37.   end if
  38.   if the machineType = 256 then
  39.     closeXLib(the pathName & "fileio.dll")
  40.   end if
  41.   set max to 0
  42.   repeat with Lin = 1 to count(TabLinIni)
  43.     if MaxCol < length(getAt(TabLinIni, Lin)) then
  44.       set MaxCol to length(getAt(TabLinIni, Lin))
  45.     end if
  46.   end repeat
  47.   set MaxLin to count(TabLinIni)
  48.   set TabLin to []
  49.   repeat with Num = 1 to MaxLin * MaxCol
  50.     add(TabLin, " ")
  51.   end repeat
  52.   repeat with Lin = 1 to count(TabLinIni)
  53.     set IndCar to 1
  54.     set linea to getAt(TabLinIni, Lin)
  55.     repeat with IndCar = 1 to length(linea)
  56.       setAt(TabLin, ((Lin - 1) * MaxCol) + IndCar, char IndCar to IndCar of linea)
  57.     end repeat
  58.   end repeat
  59.   set Deb to 1
  60.   repeat with Lin = MaxLin down to 1
  61.     repeat with Col = 1 to MaxCol
  62.       if getAt(TabLin, ((Lin - 1) * MaxCol) + Col) = "Z" then
  63.         setAt(TabLin, ((Lin - 1) * MaxCol) + Col, Deb)
  64.         set Deb to Deb + 8
  65.       end if
  66.     end repeat
  67.   end repeat
  68.   set TabDe to []
  69.   set TabA to []
  70.   set Lin to 1
  71.   repeat while Lin <= MaxLin
  72.     set Col to 1
  73.     repeat while Col <= MaxCol
  74.       set Ind to ((Lin - 1) * MaxCol) + Col
  75.       set Num to value(getAt(TabLin, Ind))
  76.       if Num > 0 then
  77.         if Col < MaxCol then
  78.           if getAt(TabLin, Ind + 1) = "-" then
  79.             set NumTr to value(getAt(TabLin, Ind + 2))
  80.             if NumTr > 0 then
  81.               add(TabDe, Primero + Num + 6)
  82.               add(TabDe, Primero + NumTr + 2)
  83.               add(TabA, Primero + NumTr + 6)
  84.               add(TabA, Primero + Num + 2)
  85.             end if
  86.           end if
  87.         end if
  88.         if Lin < MaxLin then
  89.           if (getAt(TabLin, Ind + MaxCol + 1) = "\") or (getAt(TabLin, Ind + MaxCol + 1) = "X") then
  90.             set NumTr to value(getAt(TabLin, Ind + (MaxCol * 2) + 2))
  91.             if NumTr > 0 then
  92.               add(TabDe, Primero + Num + 5)
  93.               add(TabDe, Primero + NumTr + 1)
  94.               add(TabA, Primero + NumTr + 5)
  95.               add(TabA, Primero + Num + 1)
  96.             end if
  97.           end if
  98.         end if
  99.         if (Lin < MaxLin) and (Col > 1) then
  100.           if (getAt(TabLin, Ind + MaxCol - 1) = "/") or (getAt(TabLin, Ind + MaxCol - 1) = "X") then
  101.             set NumTr to value(getAt(TabLin, Ind + (MaxCol * 2) - 2))
  102.             if NumTr > 0 then
  103.               add(TabDe, Primero + Num + 3)
  104.               add(TabDe, Primero + NumTr + 7)
  105.               add(TabA, Primero + NumTr + 3)
  106.               add(TabA, Primero + Num + 7)
  107.             end if
  108.           end if
  109.         end if
  110.         if Lin < MaxLin then
  111.           if getAt(TabLin, Ind + MaxCol) = "|" then
  112.             set NumTr to value(getAt(TabLin, Ind + (MaxCol * 2)))
  113.             if NumTr > 0 then
  114.               add(TabDe, Primero + Num + 4)
  115.               add(TabDe, Primero + NumTr)
  116.               add(TabA, Primero + NumTr + 4)
  117.               add(TabA, Primero + Num)
  118.             end if
  119.           end if
  120.         end if
  121.         set Col to Col + 2
  122.         next repeat
  123.       end if
  124.       set Col to Col + 1
  125.     end repeat
  126.     set Lin to Lin + 2
  127.   end repeat
  128.   put TabDe
  129.   put TabA
  130. end
  131.